package com.example.lenovo.mvp_demo.home.presenter;

import com.example.lenovo.mvp_demo.home.bean.Weather;
import com.example.lenovo.mvp_demo.home.contract.HomeContract;
import com.example.lenovo.mvp_demo.home.model.WeatherModel;
import com.example.lenovo.mvp_demo.home.model.WeatherModelImpl;
import com.example.lenovo.mvp_demo.home.net.callback.MyNetWorkCallback;

/**
 * Created by lenovo on 2017/7/31.
 */

public class HomePresenter implements HomeContract.Presenter {

    private HomeContract.View mView;
    private WeatherModel HomeModel;

    public HomePresenter(HomeContract.View view) {
        this.mView = view;
        this.mView.setPresenter(this);
        this.HomeModel=new WeatherModelImpl();
    }

    @Override
    public void start() {
    }


    @Override
    public void getWeather(String cityNumber) {
        mView.showProgress();
        HomeModel.getWeather(cityNumber, new MyNetWorkCallback<Weather>() {
            @Override
            public void onSuccess(Weather weather) {
                mView.showWeatherStr(weather.toString());
                mView.dimissProgress();
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                mView.dimissProgress();
            }
        });
    }
}
